import React, {Component} from 'react'
import UpListUserPage from './UpList';
import DownListComponent from './DownList';
import Actions from './ActionStore/Actions';

export default class ListAndTabs extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            rowObj: null,
            matchedRows: '', //table列表需要选中的行
        };
        this.unsubscribe = Actions.rowClickHandle.listen( (rowObj) => {
            if(rowObj.length > 0){
                this.setState({
                    rowObj: rowObj[0].data,
                    matchedRows: rowObj[0].rowIndex,
                });
            }
        });
    }

    componentWillUnmount() {
        console.log("组件销毁");
        this.unsubscribe();
    }

    render() {
        let searchCondition, matchedRows;
        if(this.state.rowObj != null){
            searchCondition = {loginName: this.state.rowObj.loginName};
            matchedRows = this.state.matchedRows;
        }
        console.log("matchedRows==========", matchedRows);
        return (
                <div>
                    <UpListUserPage matchedRows={matchedRows}/>

                    <DownListComponent searchCondition={ searchCondition } />

                </div>
        );
    }
}
